package com.ego.seckill.properties;

import com.ego.pojo.utils.IdWorker;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;

@Configuration
@EnableConfigurationProperties(IdWorkerProperties.class)
public class IdWorkerConfiguration {

    @Resource
    private IdWorkerProperties idWorkerProperties;

    @Bean
    public IdWorker idWorker() {
        return new IdWorker(idWorkerProperties.getWorkerId(), idWorkerProperties.getDatacenterId());
    }
}
